' Test ag First String Functions.txt b+ 2021-02-23& 24 reworked var functionName arg1, arg2,...

. Ways to assign a var
. var = numeric expression (this is for a variable expected to be a number)
. var "literal  (starts immediately after ") probably fastest and cleanest, remember no space!
.
. Introducing: First String Functions Case Insensitive !!! put all literals right next to comma !!!
. HEAD    Syntax: var Head source$, endCharPos#            > var = mid$(source, 1, endCharPos)
. TAIL    Syntax: var Tail source$, headEndPos#            > var = mid$(source$, headEndPos + 1)
. MID1    Syntax: var Mid1 source$, charPos#               > var = mid$(source$, charPos#, 1)
. MID$    Syntax: var Mid$ source$, startPos#, nChars#     > var = Mid$(source$, startPos#, nChars#)
. INSTR2  Syntax: var Instr2 source$,literalMatch          > var = TS$(Instr(source$, find$) 
. INSTR3  Syntax: var Instr3 start#, source$,literalMatch  > var = TS$(Instr(start#,source$, match$))
. LEN     Syntax: var Len source$                          > var = TS$(Len(source$))
. SPC     Syntax: var Spc amountOfSpaces#                  > var = SPC(amountOfSpaces)
. &       Syntax: var & a1,a2,a3,...                       > var = a1 + a2 + a3 + ...
hw "Hello World!
char_H "H
char_W "W
. Did it take? show how hw was set in code: 
' dot in next line should prevent activating "", it does.
. hw "Hello World!
' test the " method of variable assignment
. And hw has the value: ;hw;/ and char_H: ;char_H;/ and char_W: ;char_W
hwLen len hw
. And hw has the len of: ;hwLen
.
. Here we try String Functions involving MID$: Head, Tail, Mid$, Mid1
spc1 SPC 1
h6 Head hw, spc1
t6 Tail hw, spc1
low Mid$ hw, 4, 4
first Mid1 hw,1
' actually if the literal is numeric and positive you can have a space after comma.

seventh mid1 hw, 7 
. /  Head part before space = *; h6 ;*
. /   Tail part after space = *; t6 ;*
. / Mid$ from 4, 4 chars = *; low ;*
. / What's at the first (first mid1 hw,1) and seventh positions? answer: ;first;/ and ;seventh
.

find_lh instr2 hw,h
find_UH instr2 hw, char_H
find_W instr2 hw, char_W
. / Instr2 has 2 arguments: Search string and the item to match.
. / Instr3 has 3 arguments: startPlaceOfSearch, the StringToSearch, theItemToFind. 
.   Instr2 Tests:
. Any h's in ;hw;? Answer: ;find_lh
. Any H's in ;hw;? Answer: ;find_UH
. Any W's in ;hw;? Answer: ;find_W
. The original variable hw was derived from 1st letters at (find H) ;find_uH; and at (find W) ;find_W;.
. /     What the L? find all the places it's located, using Instr2, Instr3
.   Instr3 Test:
place Instr2 hw,l
[
	If place
		+= cnt,1
		.  #;cnt; l resides at ;place;# in ;hw;.
		+= place,1
		place Instr3 place, hw,l
	El
		. /      That's all the L, we found.
		Exit
	Fi
]
. /     Testing Spc n  for spaces and & arg1,arg2,arg3... concatenate with &
[
	+= n,1
	space Spc n
	bind & hw, space
	; bind
	chars = chars + hwLen + n
	Jmp chars + hwlen + n + 1 > 128
]
. 
. Goodnight!
Zzz


